layui.use(['element', 'layer'], function() {
	var element = layui.element,
		layer = layui.layer;

	//引入导航栏组件
	$('.header-row').load(requestUrl.httpUrl + 'html/common/nav.html')
	$('.footer-nav').load(requestUrl.httpUrl + 'html/common/footer.html')
	$.get(requestUrl.baseUrl + requestUrl.apiUrl.navList, function(data) {
		var menuList = data.list;
		menuList.forEach(function(curr) {
			var id = curr.id,
				parentId = curr.parentId,
				grade = curr.grade,
				name = curr.name,
				url = curr.url;
			if(grade == 1) {
				$('#meunList').append('<li class="layui-nav-item">' +
					'<a href="' + requestUrl.httpUrl + url + '">' + name + '</a>' +
					'<dl class="layui-nav-child" id="firstMenu_' + id + '">' +
					'</dl></li>')
			} else if(grade == 2) {
				$('#firstMenu_' + parentId).append('<dd><a href="' + requestUrl.httpUrl + url + '">' + name + '</a></dd>')
			}
		})
		//移除首页菜单的二级导航
		$('#firstMenu_1').prev('a').text('').next().remove();

	})

	//鼠标移入移出二级导航的显示与隐藏
	$('.header-row').on('mouseenter', '.layui-nav-item', function() {
		$(this).find('.layui-nav-child').fadeIn().parent('.layui-nav-item').siblings().find('.layui-nav-child').fadeOut();
	})
	$('.header-row').on('mouseleave', '.layui-nav-item', function() {
		$(this).find('.layui-nav-child').fadeOut();
	})
	

})

var getFiles = {
	fileList: [],
	requestGetFiles: function(recordId, attachType) {
		var that = this;
		$.post(requestUrl.baseUrl + requestUrl.apiUrl.getImage, {
			recordId: recordId,
			attachType: attachType
		}, function(data) {
			if(data.code == 0) {
				that.fileList = data.list;
			}
		})
	}
}

function getRequest() {
	var url = location.search; //获取url中"?"符后的字串   
	var theRequest = new Object();
	if(url.indexOf("?") != -1) {
		var str = url.substr(1);
		strs = str.split("&");
		for(var i = 0; i < strs.length; i++) {
			theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
		}
	}
	return theRequest;
}


